<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<base href="<%=basePath%>">
<head>
<meta charset="UTF-8">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="js/toastr.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="css/style.css" rel="stylesheet" type="text/css">
    <link href="css/toastr.css" rel="stylesheet" type="text/css">
    <title>Title</title>
</head>
<body>
<div class="container">
    <form class="login-form" action="admin/login.do" method="post">
        <h2 class="text-center">登陆管理系统</h2>
        <div class="login-wrap">
            <!-- icon_lock_alt -->
            <p class="login-img"><i class="icon_lock_alt"></i></p>
            <div class="input-group">
                <span class="input-group-addon"><i class="ace-icon fa fa-user"></i></span>
                <input type="text" id = "adminName" name="adminName" class="form-control" placeholder="用户名" autofocus required>
            </div>
            <div class="input-group" style="font-size:100px!important;">
                <span class="input-group-addon"><i class="ace-icon fa fa-lock"></i></span>
                <input type="password" id = "adminPassword" name="adminPassword" class="form-control" placeholder="密码" autofocus required>
            </div>
            <label class="checkbox" style="margin-left: 20px">
                <input type="checkbox" value="remember-me">记住我
                <span class="pull-right"> <a href="#">忘记密码?</a></span>
            </label>
            <button class="btn btn-primary btn-lg btn-block" type="button" id = "btn">登陆</button>
        </div>
    </form>
</div>
<script type="text/javascript">
	$("#btn").click(function(){
		var adminName = $("#adminName").val();
		var adminPassword = $("#adminPassword").val();
		
		$.ajax({
			url:"admin/login.do",
			type:"post",
			data:{"adminName":adminName,"adminPassword":adminPassword},
			success:function(data){
				if(data == 1){
					toastr.info("账号或密码错误")
				}else{
					toastr.info("登录成功")
					setTimeout("window.location.href='index.do'",500);
				}
				
			},
			error:function(){
				toastr.error("服务端错误")
			}
			
		})
		
	})
</script>
</body>
</html>